/*
 * NyuArray.hpp
 *
 *  Created on: 2010/05/29
 *      Author: mitsu
 */

#ifndef NYUARRAY_HPP_
#define NYUARRAY_HPP_

#include <deque>
#include "NyuObject.hpp"

class NyuContext;
class NyuArray : public NyuObject {
public:
    NyuArray(NyuObject* proto);
    NyuArray(NyuObject* proto, size_t size);
    virtual ~NyuArray();

    virtual NyuValue getitem(NyuValue idx, NyuContext* c);
    virtual void putitem(NyuValue idx, NyuValue val, NyuContext* c);

    virtual NyuValue getLength(NyuContext* c);
    virtual NyuValue push(NyuContext* c);
    virtual NyuValue pop(NyuContext* c);

    virtual void copyChildren(bool* has_new_obj);

    NyuValue& directAt(NyuInt idx) {
        return data_[idx];
    }

    static NyuValue each_func(NyuContext* c);
    static NyuValue length_func(NyuContext* c);
    static NyuValue push_func(NyuContext* c);
    static NyuValue pop_func(NyuContext* c);

private:
    std::deque<NyuValue> data_;
};

#endif /* NYUARRAY_HPP_ */
